<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>Parse_Dn</title>
    <style type=text/css>
        body {
            margin: 0 5px 0 5px;
            padding: 0 0px 0 0px;
/*            background: #F9F0DA;*/
            font-weight: 0;
            font-family: "Microsoft YaHei","宋体","Segoe UI", "Lucida Grande", Helvetica, Arial,sans-serif, FreeSans, Arimo;
        }
        #div2{
           margin-top:35px;
        }
        div.box {
            height: 53px;
            line-height: 20px;
        }
        /*输入框尺寸*/
        form {
            background: transparent;
            position: relative;
            width: 352px;
        }
 
         input, label, select {
            border: none;
            outline: none;
        }
        /*字体位置*/
        input {
            width: 77%;
            height: 32px;
            padding-left: 66px;
            padding-right: 0px;
         }
 
        label {
            text-align:center;
            line-height: 43px;
            height: 40px;
            width: 60px;
            cursor: pointer;
            position: absolute;
        }
 
        /*小框*/
        .bar label {
            background: #D06B6C;
            border-radius: 555 555px 555px 555;
            width: 60px;
            font-size: 13px;
            color: #F9F0DA;
            top: 0;
            left: 3px;
        }

        /*输入框样式*/
        .bar input {
            background: #F9F0DA;
            border: 3px solid #D06B6C;
            border-radius: 4px;

        }

        /*列表*/
        select {
            text-align:center;
            line-height:40px;
            height: 40px;
            width: 20px;
            cursor: pointer;
            position: absolute;
        }
 
        /*列表*/
        .lieb select{
            border-radius: 4px;
            background: #D06B6C;
            width: 23px;
            font-size: 13px;
            color: #F9F0DA;
            top: 0;
            right: 2px;
        }
        /*头像*/
        .round_icon{
            width: 40px;
            height: 40px;
            display: flex;
            border-radius: 50%;
            align-items: center;
            justify-content: center;
            overflow: hidden;
        }
    </style>
</head>

<body>
    <div class="fung">
        <a style="float:left;">
            <button  style="border: none;border-radius:10px;background: #c5464a;width: 80px; font-size: 18px;color: #F9F0DA;" onclick="cancel();">关 闭</button>
        </a>
        <a style="float:right">
            <button style="border: none;border-radius:10px;background: #068006;width: 80px; font-size: 18px;color: #F9F0DA;"onclick="clickme('配 置 已 保 存 ！', 1000, '开');">保 存</button> 
        </a>
    </div>
    <br>
    <div id="div2"></div>
    <div>
        <a style="float:left;margin-top:5px;" onclick="openDnPage()">
            <img src="https://s3.ax1x.com/2021/02/22/y7wb9O.jpg" class="round_icon"  alt="">
        </a>
        <span style="line-height:60px;font-size:18px;color: grey;">&nbsp;&nbsp;断&nbsp;念</span>
        <a style="float:right;margin-top:5px;">
            <button  style="border: none;border-radius:10px;background: #05BFC5;width: 185px;height:40px; font-size: 18px;color: #F9F0DA;" onclick="clickme('配 置 已 保 存 ！', 1000, '关');">保存设置并关闭界面</button>
        </a>
    <div>
</body>
<script>

    var settings = {
        qy: 'yun1717',
        yk: 'yun1717',
        tx: 'yun1717',
        mg: 'yun1717',
        bl: 'yun1717',
        oth: 'yun1717',
        qju: '默认',
        cj: 'hiker://files/cache/Parse_Dn.js'
    };
    var mySet = fy_bridge_app.fetch("hiker://files/cache/MyParseSet.json",{});
    var settings = mySet == '' ? settings : JSON.parse(mySet);
    var mySelect = fy_bridge_app.getVar('mySelect');

    function Did(id){
        return document.getElementById(id);
    }
    function getOption(id,title) {
        var obj = Did(id);
        Did(title).value = 
        obj.options[obj.selectedIndex].text;
    }
    function resetSelect(id){
        Did(id+"Select").options.selectedIndex = -1;
    }
    
    if(mySet==''){
        Did("div2").insertAdjacentHTML('afterBegin','\
<h4>提示：<br>①注意插件选项，没有手动导入插件的话不用动它。如设置不当会导致规则无法使用，<br>解决办法：视界打开更多设置→文件管理→点cache→长按MyParseSet.json删除掉；<br>②全局设置如果选择了非默认那么全部的解析会使用这一设置，不想这样的话请填入默认；<br>③绿色保存按钮仅仅保存配置不会关闭设置页面，配置后想保存并关闭设置页面的话请点蓝色按钮；<br>④阅读完提示点关闭加载完整设置页面，如出问题无法自行解决点头像进入论坛向我反馈。<br></h4>');
    }
    Did("div2").insertAdjacentHTML('afterend','\
        <div class="box bar">\
            <form>\
                <label type="submit">奇 奇</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入解析名或者URL......" value="'+settings.qy+'" id="qy">\
                <div class="lieb">\
                    <select size="2" id="qySelect" name="qy" onchange="getOption(this.id,this.name)" >'+mySelect+'\
                    </select>\
                </div>\
            </form>\
        </div>\
        <div class="box bar">\
            <form>\
                <label type="submit">酷 酷</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入解析名或者URL......" value="'+settings.yk+'" id="yk">\
               <div class="lieb">\
                    <select size="2" id="ykSelect" name="yk" onchange="getOption(this.id,this.name)" >'+mySelect+'\
                    </select>\
                </div>\
            </form>\
        </div>\
        <div class="box bar">\
            <form>\
                <label type="submit">腾 腾</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入解析名或者URL......" value="'+settings.tx+'" id="tx">\
               <div class="lieb">\
                    <select size="2" id="txSelect" name="tx" onchange="getOption(this.id,this.name)" >'+mySelect+'\
                    </select>\
                </div>\
            </form>\
        </div>\
        <div class="box bar">\
            <form>\
                <label type="submit">果 果</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入解析名或者URL......" value="'+settings.mg+'" id="mg">\
               <div class="lieb">\
                    <select size="2" id="mgSelect" name="mg" onchange="getOption(this.id,this.name)" >'+mySelect+'\
                    </select>\
                </div>\
            </form>\
        </div>\
        <div class="box bar">\
            <form>\
                <label type="submit">哩 哩</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入解析名或者URL......" value="'+settings.bl+'" id="bl">\
               <div class="lieb">\
                    <select size="2" id="blSelect" name="bl" onchange="getOption(this.id,this.name)" >'+mySelect+'\
                    </select>\
                </div>\
            </form>\
        </div>\
        <div class="box bar">\
            <form>\
                <label type="submit">其 他</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入解析名或者URL......" value="'+settings.oth+'" id="oth">\
               <div class="lieb">\
                    <select size="2" id="othSelect" name="oth" onchange="getOption(this.id,this.name)" >'+mySelect+'\
                    </select>\
                </div>\
            </form>\
        </div>\
        <div class="box bar">\
            <form>\
                <label type="submit">全 局</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入解析名或者URL......" value="'+settings.qju+'" id="qju">\
               <div class="lieb">\
                    <select size="2" id="qjuSelect" name="qju" onchange="getOption(this.id,this.name)" >\
                        <option>默认</option>\
                        '+mySelect+'\
                    </select>\
                </div>\
            </form>\
        </div>\
        <div class="box bar">\
            <form>\
                <label type="submit">插 件</label>\
                <input type="text" onclick="resetSelect(this.id)" placeholder="输入插件地址......" value="'+settings.cj+'" id="cj">\
               <div class="lieb">\
                    <select id="cjSelect" name="cj" onchange="getOption(this.id,this.name)">\
                        <option>hiker://files/cache/Parse_Dn.js</option>\
                        <option>hiker://files/rules/js/LocalParse_Dn.js</option>\
                        <option>hiker://files/rules/js/Parse-V2_Dn.js</option>\
                        <option>https://code.aliyun.com/AI957/Hiker/raw/master/v/CloudParse-V2_Dn.js</option>\
                    </select>\
                </div>\
            </form>\
        </div>\
    ');

    function Toast(msg,duration){  
        duration=isNaN(duration)?2000:duration;  
        var m = document.createElement('div');  
        m.innerHTML = msg;  
        m.style.cssText="width:45%; min-width:150px; background:#311; opacity:0.6; height:auto;min-height: 45px; color:#fff; line-height:45px; text-align:center; border-radius:10px; position:fixed; top:60%; left:26%; z-index:999999;";  
        document.body.appendChild(m);  
        setTimeout(function() {  
            var d = 0.5;  
            m.style.webkitTransition = '-webkit-transform ' + d + 's ease-in, opacity ' + d + 's ease-in';  
            m.style.opacity = '0';  
            setTimeout(function() { document.body.removeChild(m) }, d * 1000);  
        }, duration);  
    }  

    function openDnPage(){
        if(fy_bridge_app.getVar('DnPage')=='开'){
            fy_bridge_app.putVar("DnPage","关");
        }else{
            fy_bridge_app.putVar("DnPage","开");
        }
        fy_bridge_app.refreshPage(false);
    }
    function cancel(){
        if(mySet==''){
            fy_bridge_app.writeFile("hiker://files/cache/MyParseSet.json",JSON.stringify(settings, null, 4));
            fy_bridge_app.refreshPage(true);
        }else{
            fy_bridge_app.back(false);
        }
    }
    function clickme(msg,duration,title){
        var obj = [
            settings.qy=Did("qy").value,
            settings.yk=Did("yk").value,
            settings.tx=Did("tx").value,
            settings.mg=Did("mg").value,
            settings.bl=Did("bl").value,
            settings.oth=Did("oth").value,
            settings.qju=Did("qju").value,
            settings.cj=Did("cj").value,
        ];
        for (let i in obj) {
            fy_bridge_app.writeFile("hiker://files/cache/MyParseSet.json",JSON.stringify(settings, obj[i], 4));
        }
        Toast(msg,duration);
        if(title=="关"){
            fy_bridge_app.back();
        }else{
            fy_bridge_app.refreshPage(true);
        }
    }

</script>   
</html>